<template>
  <SysHeader></SysHeader>
  <!-- eslint-disable-next-line -->
  <div class="addhouse">
    <div style="font-size: 30px; display: flex; justify-content: space-between">
      <div>新建仓库</div>
      <div>
        <el-button
          @click="back"
          style="
            margin-top: 0px;
            margin-left: 0px;
            width: 100px;
            color: cornflowerblue;
          "
          >返回</el-button
        >
      </div>
    </div>
    <div style="margin-top: 30px">
      <div style="font-size: 20px">仓库名称</div>
      <div class="message">无法输入中文以及系统敏感字符</div>
    </div>
    <el-input
      onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"
      v-model="housename"
      placeholder="请输入仓库名称"
      size="large"
      style="margin-top: 5px"
    />
    <div style="margin-top: 30px">
      <div style="font-size: 20px">仓库简介</div>
      <el-input
        type="textarea"
        rows="6"
        v-model="introduce"
        size="large"
        placeholder="请输入仓库简介"
        style="margin-top: 5px"
      />
    </div>
    <div>
      <el-radio-group v-model="type" style="margin-top: 30px; margin-bottom: 0">
        <el-radio :label="1" size="large">私有的</el-radio>
        <el-radio :label="0" size="large">开源的</el-radio>
      </el-radio-group>
    </div>
    <div>
      <el-button
        @click="addhouse"
        style="margin-top: 50px; margin-left: 0px; width: 200px; color: coral"
        size="large"
        >新建仓库</el-button
      >
    </div>
  </div>
</template>
<script>
import SysHeader from "@/components/SysHeader.vue";
import request from "@/utils/request";
import { ElMessage } from "element-plus";
export default {
  name: "AssHouse",
  data() {
    return {
      housename: "",
      introduce: "",
      type: 0,
    };
  },
  methods: {
    addhouse() {
      request
        .post("/house/add", {
          housename: this.housename,
          houseintro: this.introduce,
          housetype: this.type,
        })
        .then((res) => {
          if (res.code == 200) {
            ElMessage({
              showClose: true,
              message: res.message,
              type: "success",
            });
            this.$router.push(
              "/HouseHomePage/" +
                window.sessionStorage.getItem("username") +
                "/" +
                this.housename +
                "/housecode"
            );
          } else
            ElMessage({
              showClose: true,
              message: res.message,
              type: "error",
            });
        });
    },
    back() {
      this.$router.go(-1);
    },
  },
  components: { SysHeader },
};
</script>
<style scoped>
.addhouse {
  margin-left: 20%;
  margin-right: 20%;
  margin-top: 50px;
}
.message {
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Liberation Sans",
    "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Wenquanyi Micro Hei",
    "WenQuanYi Zen Hei", "ST Heiti", SimHei, SimSun, "WenQuanYi Zen Hei Sharp",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-align: left;
  box-sizing: inherit;
  position: relative;
  min-height: 1em;
  margin: 1em 0em;
  padding: 1em 1.5em;
  line-height: 1.4285em;
  transition: opacity 0.1s ease, color 0.1s ease, background 0.1s ease,
    box-shadow 0.1s ease, -webkit-box-shadow 0.1s ease;
  font-size: 0.9em;
  border-radius: 4px;
  border: 1px solid #e3e9ed;
  background: #fff;
  margin-bottom: 10px;
  background-color: #ffe8e6;
  color: #db2828;
  box-shadow: 0px 0px 0px 1px #db2828 inset, 0px 0px 0px 0px rgba(0, 0, 0, 0);
  margin-top: 0px;
}
</style>
